import request from '@/utils/http'

// 视频相关接口
// 分页查询视频列表
export function videoSelectPage(params) {
  return request({
    url: '/selectAntiFraudVideo/page',
    method: 'get',
    params
  })
}

// 新增视频
export function videoInsertOne(data) {
  return request({
    url: '/insetAntiFraudVideo',
    method: 'post',
    data
  })
}

// 修改视频
export function videoUpdateOne(data) {
  return request({
    url: '/updateAntiFraudVideo',
    method: 'put',
    data
  })
}

// 删除视频
export function videoDeleteOne(videoId) {
  return request({
    url: `/deleteAntiFraudVideo/${videoId}`,
    method: 'delete'
  })
}

// 视频类型相关接口
// 分页查询视频类型列表
export function videoTypeSelectPage(params) {
  return request({
    url: '/MaterialType/page',
    method: 'get',
    params
  })
}

// 查询所有视频类型列表
export function videoTypeSelectList() {
  const params = {
    page: 1,
    size: 100000
  }
  return request({
    url: '/MaterialType/page',
    method: 'get',
    params
  })
}

// 新增视频类型
export function videoTypeInsertOne(data) {
  return request({
    url: '/MaterialType/add',
    method: 'post',
    data
  })
}

// 修改视频类型
export function videoTypeUpdateOne(data) {
  return request({
    url: '/update/MaterialType',
    method: 'put',
    data
  })
}

// 删除视频类型
export function videoTypeDeleteOne(typeId) {
  return request({
    url: `/delete/MaterialType/${typeId}`,
    method: 'delete'
  })
}

// 视频评论相关接口
// 查询视频评论列表
export function videoCommentSelectList(params) {
  return request({
    url: '/selectVideoReply',
    method: 'get',
    params
  })
}

// 新增视频评论
export function videoCommentInsertOne(data) {
  return request({
    url: '/video/comment',
    method: 'post',
    data
  })
}

// 删除视频评论
export function videoCommentDeleteOne(replyId) {
  return request({
    url: `/deleteVideoReply/${replyId}`,
    method: 'delete'
  })
}

// 视频上传接口
export function videoUpload(data) {
  return request({
    url: '/upload',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data
  })
}

// 物资类型相关接口
export const materialTypeSelectList = () => {
  return request({
    url: '/material/type/list',
    method: 'get'
  })
}

// 物资相关接口
export const materialSelectPage = (params) => {
  return request({
    url: '/selectMaterial/page',
    method: 'get',
    params
  })
}

export const materialInsertOne = (data) => {
  return request({
    url: '/insetMaterial',
    method: 'post',
    data
  })
}

export const materialUpdateOne = (data) => {
  if (data.createTime) {
    delete data.createTime
  }
  if (data.updateTime) {
    delete data.updateTime
  }
  return request({
    url: '/updateMaterial',
    method: 'put',
    data
  })
}

export const materialDeleteOne = (id) => {
  return request({
    url: `/deleteMaterial/${id}`,
    method: 'delete'
  })
}

// 物资申请相关接口
export const requestSelectPage = (params) => {
  return request({
    url: '/selectMaterialRequest/page',
    method: 'get',
    params: {
      ...params,
      materialId: params.materialId || undefined
    }
  })
}

export const requestUpdateStatus = (id, status) => {
  return request({
    url: `/updateMaterialStatus/${id}/${status}`,
    method: 'put'
  })
}

// 物资捐赠相关接口
export const donationSelectPage = (params) => {
  return request({
    url: '/selectDonationRecord/page',
    method: 'get',
    params: {
      ...params,
      materialId: params.materialId || undefined
    }
  })
}

export const donationUpdateStatus = (id, status) => {
  return request({
    url: `/updateDonationRecordStatus/${id}/${status}`,
    method: 'put'
  })
}
